<template>
  <div>
    <swiper
      :options="swiperOption"
      ref="mySwiper"
    >
        <swiper-slide>123</swiper-slide>
        <swiper-slide>123</swiper-slide>
        <swiper-slide>123</swiper-slide>
        <swiper-slide>123</swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>
 
<script>
// 引入插件
import { swiper, swiperSlide } from "vue-awesome-swiper";
import "swiper/dist/css/swiper.css";

export default {
  components: {
    swiper,
    swiperSlide,
  },
  props: {

  },
  data() {
    return {
      swiperOption: {
        loop: true,
        observer: true, //修改swiper自己或子元素时，自动初始化swiper
        observeParents: true,
        autoplay: {
          delay: 3000,
          stopOnLastSlide: false,
          disableOnInteraction: false,
          currentSwiperIndex: 0,
        },
        // 显示分页
        pagination: {
          el: ".swiper-pagination",
          clickable: true, //允许分页点击跳转
        },
        slidesPerView: 1.3, //100vw可以放下多少个slide
        centeredSlides: true, //是否将当前区块居中
      },
    };
  },
  methods: {
    acece() {
      alert(this.$refs.mySwiper.swiper.realIndex);
      //   获取当前swiper下标
    },
  },
  computed: {
    swiper() {
      return this.$refs.mySwiper.swiper;
    },
  },
  mounted() {},
};
</script>
<style scoped lang="less">
.swiper-container {
  position: relative;
  width: 100%;
  margin: 0.2rem 0;
  img {
    width: 100%;
    transition: all 0.5s;
    transform: scale(0.9);
    border-radius: 0.2rem;
    // transform: scale(1);
  }
}
.swiper-container .swiper-slide {
  width: 100%;
  height: 300px;
  color: #000;
  text-align: center;
    transition: all 0.5s;
}
.swiper-slide-active img {
  transform: scale(1);
}
</style>